﻿// News Framework
// (C) Tanzim Saqib. Oct 25, 2010.
// http://TanzimSaqib.com | http://newsfx.codeplex.com

namespace TanzimSaqib.NewsFramework
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Windows;
    using System.Xml.Linq;

    public class AppSettings : Dictionary<string, string>, IAppSettings
    {
        public AppSettings(string namespaceMainPage)
        {
            var streamInfo = Application.GetResourceStream(new Uri(FxConstants.AppConfigFile.FormatWith(namespaceMainPage), UriKind.Relative));

            using (var reader = new StreamReader(streamInfo.Stream))
            {
                var settings = XElement.Load(reader);

                foreach (var setting in settings.Elements())
                {
                    Add(setting.Attribute("name").Value, setting.Attribute("value").Value);
                }
            }
        }
    }
}
